<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets"
	   xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:a4j="http://richfaces.org/a4j"
	   xmlns:rich="http://richfaces.org/rich" 
      xmlns:composite="http://java.sun.com/jsf/composite">

<!-- INTERFACE -->
<composite:interface>
	<composite:attribute name="formato" />
	<composite:attribute name="formatos" />
	<composite:attribute name="campos" />
	<composite:attribute name="acao" />
</composite:interface>

<!-- IMPLEMENTATION -->
<composite:implementation>
	<rich:panel id="formatoPanel" styleClass=".form" header="Registro de formatos" headerClass="header" columnClasses="label, none">

	<h:panelGrid columns="6"  >
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Ttransação:" /></div></h:panelGroup>
		<h:inputText id="transacao" value="#{cc.attrs.formato.transacao}"   style="width:100px;" />
		<rich:message for="transacao" errorClass="invalid" />
	
		<h:panelGroup><div style="text-align:right; width:170px;"><h:outputLabel value="Formato:" /></div></h:panelGroup>
		<h:inputText id="formato" value="#{cc.attrs.formato.formato}" style="width:100px;" />
		<rich:message for="formato" errorClass="invalid" />
	</h:panelGrid>
	
	<h:panelGrid columns="3" >
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Descricao:" /></div></h:panelGroup>
		<h:inputTextarea id="descricaoFormato" value="#{cc.attrs.formato.descricao}" rows="4" cols="80" />
		<rich:message for="descricaoFormato" errorClass="invalid" />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Caso de uso:" /></div></h:panelGroup>
		<h:inputTextarea id="casoDeUso" value="#{cc.attrs.formato.casoDeUso}" rows="4" cols="80" />
		<rich:message for="casoDeUso" errorClass="invalid" />
	</h:panelGrid>
	
	<h:panelGrid columns="9" >
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Data criação:" /></div></h:panelGroup>
		<h:inputText id="dataCriacaoFormato" value="#{cc.attrs.formato.dataCriacao}" style="width:100px;" />
		<rich:message for="dataCriacaoFormato" errorClass="invalid" />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Tabela:" /></div></h:panelGroup>
		<h:inputText id="tabela" value="#{cc.attrs.formato.tabela}" style="width:100px;" />
		<rich:message for="tabela" errorClass="invalid" />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Programa:" /></div></h:panelGroup>
		<h:inputText id="programa" value="#{cc.attrs.formato.programa}" style="width:100px;" />
		<rich:message for="programa" errorClass="invalid" />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Copy book:" /></div></h:panelGroup>
		<h:inputText id="copyBook" value="#{cc.attrs.formato.copyBook}" style="width:100px;" />
		<rich:message for="copyBook" errorClass="invalid" />
		
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Matricula:" /></div></h:panelGroup>
		<h:inputText id="matricula" value="#{cc.attrs.formato.matricula}" style="width:100px;" />
		<rich:message for="matricula" errorClass="invalid" />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Sistema:" /></div></h:panelGroup>
		<h:inputText id="sistema" value="#{cc.attrs.formato.sistema}" style="width:100px;" />
		<rich:message for="sistema" errorClass="invalid" />
	
		<h:panelGroup> <div style="text-align:right; width:70px;"><h:outputLabel value="Classe tela:" /></div>	</h:panelGroup>
		<h:inputText id="classeTela" value="#{cc.attrs.formato.classeTela}" style="width:100px;" />
		<rich:message for="classeTela" errorClass="invalid"  />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Ativo:" /></div></h:panelGroup>
		<h:inputText id="ativo" value="#{cc.attrs.formato.ativo}" style="width:100px;" />
		<rich:message for="ativo" errorClass="invalid" />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Versão:" /></div></h:panelGroup>
		<h:inputText id="versaoFormato" value="#{cc.attrs.formato.versao}" style="width:100px;" />
		<rich:message for="versaoFormato" errorClass="invalid" />
	</h:panelGrid>
	
	<h:panelGrid columns="3" >
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Texto livre:" /></div></h:panelGroup>
		<h:inputTextarea id="textoLivreFormato" value="#{cc.attrs.formato.textoLivre}" rows="4" cols="80" />
		<rich:message for="textoLivreFormato" errorClass="invalid" />	
	</h:panelGrid>
	
	<h:panelGrid columns="3" >
		<a4j:commandButton action="#{cc.attrs.acao.registrar}" 	value="Registrar" styleClass="register" title="Clique para incluir/alterar"/>
		<a4j:commandButton action="#{cc.attrs.acao.exclua}" value="Excluir" styleClass="register" title="Clique para excluir">
			<f:setPropertyActionListener target="#{cc.attrs.acao.idFormato}" value="#{cc.attrs.formato.formato}" />
		</a4j:commandButton>
		<a4j:commandButton action="#{cc.attrs.acao.novoFormato}" value="Novo" styleClass="register" title="Clique para criar um novo formato"/>
	</h:panelGrid>
	
	<h:messages styleClass="messages" errorClass="invalid" infoClass="valid" warnClass="warning" globalOnly="true" />
</rich:panel>
	
<rich:collapsiblePanel id="listaFormatos" header="Formatos" headerClass="header" title="Click to expand/collapse">
   <h:panelGroup rendered="#{empty cc.attrs.formatos}">
      <em>Nenhum formato registrado.</em>
   </h:panelGroup>
   <rich:dataTable var="item" value="#{cc.attrs.formatos}" rendered="#{not empty cc.attrs.formatos}" style="width : 100%">
	   <rich:column>
			<a4j:commandLink action="#{cc.attrs.acao.buscaFormato}" styleClass="no-decor" render="formatoPanel" > Visualiza
				<f:setPropertyActionListener target="#{cc.attrs.acao.idFormato}" value="#{item.formato}" />
			</a4j:commandLink>
           </rich:column>
		<rich:column>
			<f:facet name="header">Formato</f:facet>  #{item.formato}
           </rich:column>
		<rich:column>
			<f:facet name="header">Descrição</f:facet> #{item.descricao}
           </rich:column>
		<rich:column>
			<f:facet name="header">Tabela</f:facet> #{item.tabela}
            </rich:column>
	</rich:dataTable>
</rich:collapsiblePanel>	
</composite:implementation>
</html>